import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router';

const routes = [
  {
    path: '/',
    name: 'evaluation',
    component: () => import('../views/evaluation.vue'),
  },
]
 
// evaluation文件夹下有一些组件需要被导入
const modules = import.meta.glob('/src/views/evaluation/*.vue', { eager: true });
 
// 路由配置数组
const loadRoutes = Object.keys(modules).map((path) => {
  // 获取路径和组件名称
  const componentName = path.split('/').pop().replace(/\.\w+$/, '');
 
  // 返回路由对象
  return {
    path: `/${componentName}`,
    component: modules[`${path}`].default || modules[`${path}`],
  };
});

// 创建router实例
const router = createRouter({
  history: createWebHashHistory(),
  routes: [...routes, ...loadRoutes],
});
 
export default router;